Test

Test

import pandas as pd
import seaborn as sns
import plotly.express as px
cities = pd.read_json('https://www.visimarsrutai.lt/services-ext/api/municipalities')

for city in cities:
  File "/tmp/ipykernel_2138/3447593251.py", line 3
    for city in cities:
                       ^
IndentationError: expected an indented block after 'for' statement on line 3
from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
    counties = json.load(response)

import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv",
                 dtype={"fips": str})

import plotly.express as px

fig = px.choropleth_mapbox(df, geojson=counties, locations='fips', color='unemp',
                           color_continuous_scale="Viridis",
                           range_color=(0, 12),
                           mapbox_style="carto-positron",
                           zoom=3, center = {"lat": 37.0902, "lon": -95.7129},
                           opacity=0.5,
                           labels={'unemp':'unemployment rate'}
                           )
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
import plotly.express as px

df = px.data.election()
geojson = px.data.election_geojson()

fig = px.choropleth_mapbox(df, geojson=geojson, color="winner",
                           locations="district", featureidkey="properties.district",
                           center={"lat": 45.5517, "lon": -73.7073},
                           mapbox_style="carto-positron", zoom=9)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
import pandas as pd
import plotly.express as px

#import dataset
df = pd.read_csv('https://covid.ourworldindata.org/data/owid-covid-data.csv')

#select entries with the continent as asia
df = df[df['date'] == '2021-02-04']
df = df[df.continent == 'Asia']

display(df)
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
    counties = json.load(response)

#plot
fig = px.choropleth(df, geojson=counties, locations="iso_code",
                    color="new_cases",
                    hover_name="location",
                           featureidkey="properties.district",
                    title = "Daily new COVID cases",
                     color_continuous_scale=px.colors.sequential.PuRd,
                        )

fig["layout"].pop("updatemenus")
fig.show()
iso_code continent location date total_cases new_cases new_cases_smoothed total_deaths new_deaths new_deaths_smoothed ... female_smokers male_smokers handwashing_facilities hospital_beds_per_thousand life_expectancy human_development_index excess_mortality_cumulative_absolute excess_mortality_cumulative excess_mortality excess_mortality_cumulative_per_million
346 AFG Asia Afghanistan 2021-02-04 55231.0 57.0 48.571 2407.0 1.0 1.429 ... NaN NaN 37.746 0.50 64.83 0.511 NaN NaN NaN NaN
6782 ARM Asia Armenia 2021-02-04 167568.0 147.0 128.429 3107.0 11.0 5.714 ... 1.5 52.1 94.043 4.20 75.09 0.776 NaN NaN NaN NaN
10409 AZE Asia Azerbaijan 2021-02-04 230769.0 152.0 139.429 3148.0 3.0 5.000 ... 0.3 42.5 83.241 4.70 73.00 0.756 NaN NaN NaN NaN
11824 BHR Asia Bahrain 2021-02-04 105496.0 704.0 570.429 377.0 1.0 0.714 ... 5.8 37.6 NaN 2.00 77.29 0.852 NaN NaN NaN NaN
12534 BGD Asia Bangladesh 2021-02-04 537030.0 485.0 439.571 8175.0 13.0 12.571 ... 1.0 44.7 34.808 0.80 72.59 0.632 NaN NaN NaN NaN
17470 BTN Asia Bhutan 2021-02-04 859.0 0.0 0.286 1.0 0.0 0.000 ... NaN NaN 79.807 1.70 71.78 0.654 NaN NaN NaN NaN
22348 BRN Asia Brunei 2021-02-04 180.0 0.0 0.000 3.0 0.0 0.000 ... 2.0 30.9 NaN 2.70 75.86 0.838 NaN NaN NaN NaN
25184 KHM Asia Cambodia 2021-02-04 470.0 3.0 1.000 NaN NaN NaN ... 2.0 33.7 66.229 0.80 69.82 0.594 NaN NaN NaN NaN
30893 CHN Asia China 2021-02-04 89669.0 20.0 41.571 4636.0 0.0 0.000 ... 1.9 48.4 NaN 4.34 76.91 0.761 NaN NaN NaN NaN
55295 GEO Asia Georgia 2021-02-04 260480.0 583.0 599.000 3240.0 19.0 16.143 ... 5.3 55.5 NaN 2.60 73.77 0.812 NaN NaN NaN NaN
65647 HKG Asia Hong Kong 2021-02-04 10552.0 22.0 33.000 186.0 1.0 1.286 ... NaN NaN NaN NaN 84.86 0.949 NaN NaN NaN NaN
67814 IND Asia India 2021-02-04 10802591.0 12408.0 11791.857 154823.0 120.0 116.143 ... 1.9 20.6 59.550 0.53 69.66 0.645 NaN NaN NaN NaN
68525 IDN Asia Indonesia 2021-02-04 1123105.0 11434.0 12158.857 31001.0 231.0 238.571 ... 2.8 76.1 64.204 1.04 71.72 0.718 NaN NaN NaN NaN
69983 IRN Asia Iran 2021-02-04 1445326.0 7040.0 6640.714 58256.0 67.0 74.286 ... 0.8 21.1 NaN 1.50 76.68 0.783 NaN NaN NaN NaN
70701 IRQ Asia Iraq 2021-02-04 624222.0 1150.0 1002.857 13091.0 12.0 9.571 ... NaN NaN 94.576 1.40 70.60 0.674 NaN NaN NaN NaN
72829 ISR Asia Israel 2021-02-04 675618.0 6744.0 6674.714 5001.0 53.0 47.429 ... 15.4 35.4 NaN 2.99 82.97 0.919 NaN NaN NaN NaN
75024 JPN Asia Japan 2021-02-04 400069.0 2578.0 2697.429 6176.0 104.0 96.429 ... 11.2 33.7 NaN 13.05 84.63 0.919 NaN NaN NaN NaN
76064 JOR Asia Jordan 2021-02-04 331768.0 1294.0 1085.571 4354.0 10.0 12.143 ... NaN NaN NaN 1.40 74.53 0.729 NaN NaN NaN NaN
76764 KAZ Asia Kazakhstan 2021-02-04 240983.0 1257.0 1323.857 3126.0 0.0 13.000 ... 7.0 43.1 98.999 6.70 73.60 0.825 NaN NaN NaN NaN
79157 KWT Asia Kuwait 2021-02-04 168250.0 840.0 685.714 962.0 1.0 0.571 ... 2.7 37.0 NaN 2.00 75.49 0.806 NaN NaN NaN NaN
79852 KGZ Asia Kyrgyzstan 2021-02-04 84920.0 88.0 88.143 1420.0 2.0 1.714 ... 3.6 50.5 89.220 4.50 71.45 0.697 NaN NaN NaN NaN
80541 LAO Asia Laos 2021-02-04 45.0 0.0 0.143 NaN NaN NaN ... 7.3 51.2 49.839 1.50 67.92 0.613 NaN NaN NaN NaN
81978 LBN Asia Lebanon 2021-02-04 312269.0 3107.0 2730.286 3397.0 82.0 110.857 ... 26.9 40.7 NaN 2.90 78.93 0.744 NaN NaN NaN NaN
88383 MAC Asia Macao 2021-02-04 47.0 0.0 0.000 NaN NaN NaN ... NaN NaN NaN NaN 84.24 NaN NaN NaN NaN NaN
90509 MYS Asia Malaysia 2021-02-04 231483.0 4571.0 4753.571 826.0 17.0 15.571 ... 1.0 42.4 NaN 1.90 76.16 0.810 NaN NaN NaN NaN
91214 MDV Asia Maldives 2021-02-04 16410.0 134.0 130.571 54.0 1.0 0.429 ... 2.1 55.0 95.803 NaN 78.92 0.740 NaN NaN NaN NaN
97754 MNG Asia Mongolia 2021-02-04 1890.0 31.0 28.286 2.0 0.0 0.000 ... 5.5 46.5 71.180 7.00 69.87 0.737 NaN NaN NaN NaN
101257 MMR Asia Myanmar 2021-02-04 141104.0 177.0 278.857 3163.0 3.0 8.571 ... 6.3 35.2 79.287 0.90 67.13 0.583 NaN NaN NaN NaN
102990 NPL Asia Nepal 2021-02-04 271602.0 171.0 144.857 2033.0 2.0 1.857 ... 9.5 37.8 47.782 0.30 70.78 0.602 NaN NaN NaN NaN
109117 OWID_CYN Asia Northern Cyprus 2021-02-04 NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
111224 OMN Asia Oman 2021-02-04 135041.0 185.0 187.571 1532.0 0.0 0.714 ... 0.5 15.6 97.400 1.60 77.86 0.813 NaN NaN NaN NaN
111941 PAK Asia Pakistan 2021-02-04 551842.0 1302.0 1544.429 11886.0 53.0 46.571 ... 2.8 36.7 59.607 0.60 67.27 0.557 NaN NaN NaN NaN
112822 PSE Asia Palestine 2021-02-04 161087.0 661.0 499.143 1865.0 8.0 7.571 ... NaN NaN NaN NaN 74.05 0.708 NaN NaN NaN NaN
116440 PHL Asia Philippines 2021-02-04 531699.0 1581.0 1732.000 10997.0 55.0 63.571 ... 7.8 40.8 78.463 1.00 71.23 0.718 NaN NaN NaN NaN
118659 QAT Asia Qatar 2021-02-04 152898.0 407.0 374.000 249.0 0.0 0.143 ... 0.8 26.9 NaN 1.20 80.23 0.848 NaN NaN NaN NaN
126651 SAU Asia Saudi Arabia 2021-02-04 369248.0 303.0 281.714 6389.0 3.0 3.286 ... 1.8 25.4 NaN 2.70 75.13 0.854 NaN NaN NaN NaN
130211 SGP Asia Singapore 2021-02-04 59624.0 22.0 28.429 29.0 0.0 0.000 ... 5.2 28.3 NaN 2.40 83.62 0.938 NaN NaN NaN NaN
135315 KOR Asia South Korea 2021-02-04 80131.0 369.0 390.857 1459.0 11.0 8.571 ... 6.2 40.9 NaN 12.27 83.03 0.916 NaN NaN NaN NaN
137479 LKA Asia Sri Lanka 2021-02-04 67115.0 706.0 789.857 339.0 7.0 6.000 ... 0.3 27.0 NaN 3.60 76.98 0.782 NaN NaN NaN NaN
141027 SYR Asia Syria 2021-02-04 14267.0 65.0 54.571 938.0 5.0 4.571 ... NaN NaN 70.598 1.50 72.70 0.567 NaN NaN NaN NaN
141784 TWN Asia Taiwan 2021-02-04 919.0 2.0 3.429 9.0 1.0 0.286 ... NaN NaN NaN NaN 80.46 NaN NaN NaN NaN NaN
142435 TJK Asia Tajikistan 2021-02-04 13714.0 0.0 0.000 91.0 0.0 0.000 ... NaN NaN 72.704 4.80 71.10 0.668 NaN NaN NaN NaN
143901 THA Asia Thailand 2021-02-04 22058.0 809.0 833.857 79.0 0.0 0.429 ... 1.9 38.8 90.670 2.10 77.15 0.777 NaN NaN NaN NaN
144592 TLS Asia Timor 2021-02-04 80.0 3.0 1.714 NaN NaN NaN ... 6.3 78.1 28.178 5.90 69.50 0.606 NaN NaN NaN NaN
147822 TUR Asia Turkey 2021-02-04 2508988.0 7909.0 7410.000 26467.0 113.0 123.143 ... 14.1 41.1 NaN 2.81 77.69 0.820 NaN NaN NaN NaN
151015 ARE Asia United Arab Emirates 2021-02-04 316875.0 3249.0 3403.286 888.0 10.0 9.857 ... 1.2 37.4 NaN 1.20 77.97 0.890 NaN NaN NaN NaN
154657 UZB Asia Uzbekistan 2021-02-04 78916.0 57.0 51.429 621.0 0.0 0.000 ... 1.3 24.7 NaN 4.00 71.72 0.720 NaN NaN NaN NaN
157271 VNM Asia Vietnam 2021-02-04 1957.0 9.0 43.714 35.0 0.0 0.000 ... 1.0 45.9 85.847 2.60 75.40 0.704 NaN NaN NaN NaN
159174 YEM Asia Yemen 2021-02-04 2122.0 0.0 0.286 615.0 0.0 0.000 ... 7.6 29.2 49.542 0.70 66.12 0.470 NaN NaN NaN NaN

49 rows × 67 columns

---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
/var/folders/xn/22j1lv3156v72t9_vtdcvn8r0000gn/T/ipykernel_9038/2139765566.py in <module>
     11 display(df)
     12 with urlopen('http://ccksp.gnf.tf/sites/default/files/ne_110m_admin_0_countries_geojson.csv') as response:
---> 13     counties = json.load(response)
     14 
     15 #plot

/opt/homebrew/anaconda3/lib/python3.9/json/__init__.py in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    291     kwarg; otherwise ``JSONDecoder`` is used.
    292     """
--> 293     return loads(fp.read(),
    294         cls=cls, object_hook=object_hook,
    295         parse_float=parse_float, parse_int=parse_int,

/opt/homebrew/anaconda3/lib/python3.9/json/__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    344             parse_int is None and parse_float is None and
    345             parse_constant is None and object_pairs_hook is None and not kw):
--> 346         return _default_decoder.decode(s)
    347     if cls is None:
    348         cls = JSONDecoder

/opt/homebrew/anaconda3/lib/python3.9/json/decoder.py in decode(self, s, _w)
    335 
    336         """
--> 337         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338         end = _w(s, end).end()
    339         if end != len(s):

/opt/homebrew/anaconda3/lib/python3.9/json/decoder.py in raw_decode(self, s, idx)
    353             obj, end = self.scan_once(s, idx)
    354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
    356         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)